﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xeml.Document;
using Xeml.Sampling.Contracts;

namespace Xid.Controls
{
    /// <summary>
    /// a helper class for databinding of sample mappings
    /// </summary>
    public class SampleMapping
    {
        internal int _id = -1;

        #region constructors
        public SampleMapping(SidMapping sidMapping, SidLookUpResult lookUp)
        {
            SidMapping = sidMapping;
            LookUp = lookUp;
        }

        public SampleMapping(SidMapping sid)
        {
            _sid = sid;
        }
        #endregion constructors

        public int SampleId
        {
            get { return _sid == null ? _id : _sid.SampleId; }
        }

        private string _keymapping;
        public string ForeignKeyMapping
        {
            get
            {
                if (_sid == null)
                    return _keymapping;
                else
                    return _sid.ForeignKeyMap;
            }
            set
            {
                if (_sid == null)
                    _keymapping = value;
                else
                    _sid.ForeignKeyMap = value;
            }
        }

        private SidLookUpResult _lookup = SidLookUpResult.UnknownSample;
        public SidLookUpResult LookUp
        {
            get { return _lookup; }
            set { _lookup = value; }
        }

        private SidMapping _sid;
        public SidMapping SidMapping
        {
            get { return _sid; }
            set { _sid = value; _lookup = SidLookUpResult.UnknownSample; }
        }
    }

    public class SampleMappings : List<SampleMapping>
    {
    }
}
